package com.xjl.user.dbArchiving.archiving.factory;

import com.xjl.user.dbArchiving.archiving.BackUpDatahandler;
import com.xjl.user.dbArchiving.enums.BackUpDataSceneEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Objects;

@Service
@Slf4j
public class BackUpServiceImpl implements BackUpService{

    @Resource
    private BackUpDataFactory backUpDataFactory;

    @Override
    public void backup(BackUpDataSceneEnum sceneEnum) {
        log.info("BackUpServiceImpl.backUp.scene:{}!", sceneEnum.getCode());
        BackUpDatahandler backUpDataHandler = backUpDataFactory.getHandlerByCode(sceneEnum.getCode());
        if (Objects.isNull(backUpDataHandler)) {
            log.info("BackUpServiceImpl.noFindScene!");
            return;
        }
        backUpDataHandler.backUpData();
    }

}
